
import { getToken, setToken, removeToken } from '@/utils/auth'
import { resetRouter } from '@/router'

export default {
  namespaced: true,
  state: {
    token: getToken() || '1635197364'
  },
  mutations: {
    SET_TOKEN(state, token) {
      state.token = token
      setToken(token)
    },
    REMOVE_TOKEN(state) {
      state.token = ''
      removeToken()
      // 重置路由
      resetRouter()
    }
  },
  actions: {
    fetchLogin(store, loginForm) {
      // const { data } = await login(loginForm)
      store.commit('SET_TOKEN', 1635197364)
      return
    }
  }
}

